<?php

namespace app\index\controller;

use thinkct\controller\Frontend;
use think\facade\Db;

class Test
{

    public function users()
    {
        $users = Db::name('users')->select();
        foreach ($users as $user) {
            // 写入到新user
            $user['date'] = $user['date']? $user['date'] : '2020-01-01 00:00:00';
            $join_time = strtotime($user['date']);

            Db::name('user')->insert([
                'username' => $user['name'],
                'nickname' => $user['name'],
                'password' => $user['password'],
                'email' => $user['email']? $user['email'] : '',
                'mobile' => $user['phone']? $user['phone'] : '',
                'qq' => $user['qq']? $user['qq'] : '',
                'gender' => 1,
//                'avatar' => $user['avatar'],
                'join_ip' => $user['logIp']? $user['logIp'] : '',
                'join_time' => $join_time,
                'update_time' => $join_time,
                'create_time' => $join_time,
            ]);
            echo $user['name'] . "<br>";
        }
    }
}